package com.pinecone.controller;

import com.pinecone.common.utils.R;
import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by hushangjie on 2017/9/18.
 */
@RestController
public class QiNiuController {
    @Value("${qiniu.AccessKey}")
    private String ak;
    @Value("${qiniu.SecretKey}")
    private String sk;
    @Autowired
    @GetMapping("/qiniu_token")
    public R getUploadToken(){

        Auth auth = Auth.create(ak,sk);
        String token = auth.uploadToken("pinecone-live");
        return R.ok().put("token",token);
    }
}
